var of = require('OverFish');

admin = function (app){
    app.get('/:module?/:controller?/:action?', function(req, res)
    {
        of.response = res;
        
        req.params.env = 'backend';
        
        if (req.params.module == undefined)
        {
          req.params.module = 'default';
          req.params.controller = 'dashboard';
          req.params.action = 'default';
        }
        else if (req.params.controller == undefined)
        {
          req.params.controller = 'default';
          req.params.action = 'default';
        }
        else if (req.params.action == undefined)
        {
          req.params.action = 'default';
        }
        
        of.route(req, {
            'module': req.params.module,
            'controller': req.params.controller,
            'action': req.params.action,
            'env': req.params.env
          });
    });
}

exports.admin = admin;
exports.routers = [{'namespace': 'admin', 'callback': admin}];